package org.example.springbootproject.mapper;

import org.apache.ibatis.annotations.*;
import org.example.springbootproject.pojo.Goods;
import org.example.springbootproject.pojo.Outbound;

import java.time.LocalDate;
import java.util.List;

@Mapper
public interface OutboundMapper {
    @Select("select * from outbound")
    List<Outbound> findOutbound();

    @Select("select count(*) from goods")
    int findGoodsCount();

    @Select("select * from goods order by storage_time limit 1")
    Goods findGoods();

    @Update("update goods set inbound_tonnage = #{tempTon} where id = #{tempId}")
    void updateGoods(Double tempTon, int tempId);

    @Select("select id from goods order by storage_time asc limit 1")
    Integer getFirstId();

    @Insert("insert into outbound(order_number, lading_number, sailing_day, outbound_qty, outbound_ton, business_id, storage_fees, remaining_tonnage) " +
    "values (#{orderNumber},#{ladingNumber},#{sailingDay},#{outboundQty},#{outboundTon},#{businessId},#{storageFees},#{remainingTonnage})")
    void addOutbound(LocalDate sailingDay,String orderNumber,Integer outboundQty,Double outboundTon,String ladingNumber,String businessId,Double storageFees,Double remainingTonnage);

    @Delete("delete from goods order by storage_time asc limit 1")
    void deleteGoods();

    @Select("select sum(inbound_tonnage) from goods")
    Double getremainton();
}
